const { SHOW_ITEM_TYPE } = require("../../config/mod_def");
const { UI_Layer } = require("../../config/ui_def");

cc.Class({
    extends: cc.Component,

    properties: {
    },
    initPage(){

    },
    updatePage(){

    },
    getGoPass(event){
        let value = parseInt(event.string)
        if(isNaN(value)){
            gg.uiManager.addTip("参数不是数字")
        }
        let pass_id = parseInt(value)
        if(he.db.getData("Pass",pass_id)){
            gg.data.goPass(pass_id)
            gg.uiManager.addPage(UI_Layer.Load, {
                name: "LoadCover",
                in: true,
                scene: 'Playground'
            })
        }else{
            gg.uiManager.addTip("妹有这一关")
        }
    },
    getItemFunc(event){
        if(event.string.indexOf('#') <= 0){
            gg.uiManager.addTip("格式错误")
            return
        }
        let param_list = event.string.split("#")
        let item_info = he.db.getData("Item",parseInt(param_list[0]))
        if(item_info){
            gg.data.addItem(item_info,parseInt(param_list[1]),SHOW_ITEM_TYPE.BY_INFO)
            gg.uiManager.addTip("添加成功，刷新预览")
        }else{
            gg.uiManager.addTip("没有对应道具")
        }
    }

    // update (dt) {},
});
